#include "optiondialog.h"
#include "tab1dialog.h"
#include "tab2dialog.h"
#include "tab3dialog.h"
#include "ui_optiondialog.h"

#include <QSettings>
#include <QPushButton>


OptionDialog::OptionDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::OptionDialog)
{
    ui->setupUi(this);
    listinitiation();

    ui->stackedWidget->insertWidget(0,&tab1);
    ui->stackedWidget->insertWidget(1,&tab2);
    ui->stackedWidget->insertWidget(2,&tab3);
    ui->stackedWidget->insertWidget(3,&tab4);
    ui->stackedWidget->setCurrentIndex(0);
  //  ui->stackedWidget->setStyleSheet("background-color:rgba(255,255,255,255);");

    ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr("OK"));
    ui->buttonBox->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
}

OptionDialog::~OptionDialog()
{
    delete ui;
}

void OptionDialog::listinitiation()
{
    QListWidget *listWidget = ui->listWidget;
    listWidget->addItem(tr("maxDisplaySize"));
    listWidget->addItem(tr("BID"));
    listWidget->addItem(tr("chartSetting"));
    listWidget->addItem(tr("colors and Fonts"));

    listWidget->item(0)->setSelected(true);
}


void OptionDialog::on_listWidget_itemClicked(QListWidgetItem *item)
{
    ui->stackedWidget->setCurrentIndex(ui->listWidget->currentRow());
}


void OptionDialog::on_buttonBox_clicked(QAbstractButton *button)
{
    if (button == ui->buttonBox->button(QDialogButtonBox::Ok)) {
        tab1.savedata();
        tab2.savedata();
        tab3.savedata();
        tab4.savadata();

        emit buttonboxclicked();
    }

    this->close();
}

